from pathlib import Path


def root_path(dir: Path = Path()) -> Path:
    for path in dir.parents:
        if (path / '.repo').exists():
            return path
    return dir
